

const { app, BrowserWindow, ipcMain,Menu } = require('electron')
const path = require('path')
const isDev = require('electron-is-dev')
const menuTemplate = require('./menuTemplate')
const { start, end } = require('../koa2/bin/www.js')
console.log(isDev)
function createWindow() {
    // 创建浏览器窗口
    const win = new BrowserWindow({
        width: 800,
        height: 600,
        backgroundColor: '#fff',
        webPreferences: {
            enableRemoteModule:true,
            nodeIntegration: true
        }
    })
   


    const urlLocation = isDev ? 'http://127.0.0.1:3000' : `file://${path.join(__dirname, './build/index.html')}`
    win.loadURL(urlLocation)
   
    start()
}
let menu = Menu.buildFromTemplate(menuTemplate())
Menu.setApplicationMenu(menu)
// mainWindow.webContents.openDevTools()
ipcMain.on('config-is-saved', () => {
    let menu = Menu.buildFromTemplate(menuTemplate())
    Menu.setApplicationMenu(menu)
})
app.whenReady().then(createWindow)
